﻿
nums = [
    [19, 50, 10, 37, 82, 31],
    [25, 61, 39, 88, 43, 57],
    [10, 10, 28, 32, 45, 92],
    [33, 21, 87, 10, 54, 48],
    [10, 10, 44, 66, 83, 32],
    [75, 53, 49, 10, 11, 92],
    [55, 83, 29, 70, 62, 43]
    ]
# 这里map函数仅考虑周围有8个值的点
all_row=len(nums)         #7行
all_col=len(nums[0])      #6列

def my_map(nums):
    # 定义结果
    result_path = {}
    # 搜索集
    each_path = {}
    # 行数
    row = len(nums)     #7行
    # 列
    col = len(nums[0])  #6列

    for i in range(row):
        for k in range(col):
            each_path[(i+1,k+1)] = nums[i][k]
           # print(i+1,k+1)
    for j in range(1,row-1):       #循环从1开始，因为第0行或者第0列的任一元素周围没有八个元素，
        for h in range(1,col-1):   #同理最后一行或者最后一列的任意元素周围也没有八个元素
            result_path[(j+1,h+1)] = [
                each_path[(j,h)],
                each_path[(j,h+1)],
                each_path[(j,h+2)],
                each_path[(j+1,h)],
                each_path[(j+1,h+2)],
                each_path[(j+2,h)],
                each_path[(j+2,h+1)],
                each_path[(j+2,h+2)]
                ]

    return result_path
path = my_map(nums)
#print(path)


def my_reduce(tuple,path):
    sum = 0
    for i in path[tuple]: #遍历元组，求元组所有元素和
        sum = sum + i
    return '{} --> {}'.format(tuple,sum/8)  #返回八个元素的平均值

a = int(input("请输入一个整数："))
b = int(input("请输入一个整数："))
if(a-1 <= 0 or a-1 > all_row)and (b-1 <= 0 or b-1 > all_col):
    print("请重新输入")
else:
    print(my_reduce((a,b),path))


